<template>
  <view>
    <!-- #ifndef  H5 -->
    <u-sticky offset-top="0" h5-nav-height="0" bg-color="transparent">
      <u-navbar
          :is-back="true"
          :title-bold="true"
          :is-fixed="false"
          :title="nav_title"
          title-color="#000000"
          :border-bottom="false"
          back-icon-name="arrow-leftward"
          back-icon-color="#000000"
          :background="{ background: 'rgba(256,256, 256,0)' }"
      ></u-navbar>
    </u-sticky>
    <!-- #endif -->
    <!--pages/server_explan/server_explan.wxml-->
    <view class="main">

      <view class="content">
        <u-parse :html="article_content"/>
      </view>

    </view>

    <!--<import src="/wxParse/wxParse.wxml"></import>-->
  </view>
</template>

<script>

import {getServerProto, getPrivatePolicy, getAfterSaleGuar} from '@/api/app';

export default {
  data() {
    return {
      article_content: "",
      nav_title: ""
    };
  },

  components: {},
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let {
      type
    } = options;
    type = parseInt(type); // 0 ==> 服务协议 1 ==> 隐私政策 2 ==> 售后保障

    // 使用对象映射设置标题
    const titleMap = {
      0: '注册协议',
      1: '隐私协议',
      2: '责任声明'
    };
    this.nav_title = titleMap[type] || '注册协议';

    switch (type) {
      case 0:
        this.getServerProtoFun();
        break;

      case 1:
        this.getPrivatePolicyFun();
        break;

      case 2:
        this.getAfterSaleGuarFun();
        break;

      default:
        this.getServerProtoFun();
        break;
    }
  },
  methods: {
    // 服务协议
    getServerProtoFun() {
      getServerProto().then(res => {
        if (res.code == 1) {
          //wxParse.wxParse('content', 'html', res.data, this, 15)
          setTimeout(() => {
            this.article_content = res.data;
          }, 200);
        }
      });
    },

    // 隐私协议
    getPrivatePolicyFun() {
      getPrivatePolicy().then(res => {
        if (res.code == 1) {
          //wxParse.wxParse('content', 'html', res.data, this, 15)
          setTimeout(() => {
            this.article_content = res.data;
          }, 200);
        }
      });
    },

    // 售后保障
    getAfterSaleGuarFun() {
      getAfterSaleGuar().then(res => {
        if (res.code == 1) {
          //wxParse.wxParse('content', 'html', res.data, this, 15)
          setTimeout(() => {
            this.article_content = res.data;
          }, 200);
        }
      });
    }

  }
};
</script>
<style lang="scss">
page {
  background-image: url("../../static/images/my_bg.jpg");
  background-size: 100%;
  background-repeat: no-repeat;
  /* pages/server_explan/server_explan.wxss */

  .main {
    padding: 20rpx;
    /* min-height: 100vh; */
    .content{
      padding: 20rpx;
      background-color: #fff;
      border-radius: 16rpx;
      color:#747474;
    }
  }
}
</style>